package com.example.doer.reading.AppAdapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.doer.reading.AppDataModel.MyInfoList;
import com.example.doer.reading.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by pc on 2017/7/13.
 */

public class MyInfoListViewAdapter extends BaseAdapter{
    Context context;
    int res;
    List<MyInfoList> list = new ArrayList<MyInfoList>();

    public MyInfoListViewAdapter(Context c, List<MyInfoList> l, int r)
    {
        this.context = c;
        this.list = l;
        this.res = r;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public MyInfoList getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        View view1 = LayoutInflater.from(context).inflate(res,null);
        MyInfoList Info = getItem(i);


        ImageView imageView=(ImageView)view1.findViewById(R.id.imageView5);

        TextView tv_1 = (TextView)view1.findViewById(R.id.tv_InfoList);

        imageView.setImageResource(Info.getResID());
        tv_1.setText(Info.getText());

        return view1;
    }
}


